module ApplicationHelper
  def include_javascript_by_namespace
    namespace = params[:controller].split('/')[0]
    if ["ruiqu", "ems", "settings"].include?(namespace)
      content_for :pre_assets do
        javascript_include_tag namespace
      end
    end
  end

  def link_stylesheet_by_namespace
    namespace = params[:controller].split('/')[0]
    if ["ems", "ruiqu", "settings"].include?(namespace)
      content_for :pre_assets do
        stylesheet_link_tag namespace
      end
    end
  end

  def flash_class(level)
    case level
    when :notice then "alert alert-info"
    when :success then "alert alert-success"
    when :error then "alert alert-error"
    when :alert then "alert alert-error"
    end
  end

  def method_use_time(&block)
    puts Benchmark.measure(&block)
    # s.orders.select(:store_customer_id).uniq.pluck(:store_customer_id)
    # s.orders.map(&:store_customer_id).uniq
  end

end
